/**
 * File: cs3343-Satir-Therapy/src/program/Player.java
 *  
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.0.0
 * Checked in at date: 2012/02/12 15:44
 * Checked out at date: 2012/02/15 21:57
 * Log: definition of Player(), constructor of Player(id, name), move method
 * 
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.1.0
 * Checked in at date: 2012/02/15 22:11
 * Checked out at date: 2012/02/21 23:05
 * Log: getName()
 * 
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.2.0
 * Checked in at date: 2012/02/28 09:50
 * Checked out at date: 2012/03/05 20:48
 * Log: default constructor Player(), redefine Player(id, name) into Player(id, name, position),
 * 		add getID()
 * 
 * Responsible author: Lai Hing Hung, Dennis					Revision no: 1.3.0
 * Checked in at date: 2012/04/06 16:52
 * Log: add addCard(), addSelfEsteem(), deleteCard(), getID(), getMagicTool(), getName() getPosition()
 * 		getRole(), getSelfEsteem(), hasMagicCrown(), hasMagicGlove(), hasMagicKey(), hasMagicMirror()
 * 		getMagicRod(), hasMagicShield(), hasMagicTools() and move() methods
 * 
 */
package program;
import java.util.*;

public class Player {
	private String number;
	private String name;
	private int position;
	private String role;
	private int selfEsteem;
	private Vector<Card> cards;
	
	public Player(){
		
	}
	
	// Player constructor for creation of player
	public Player(String id, String name, String role, int position, int selfEsteem){
		this.number = id;
		this.name = name;
		this.role = role;
		this.position = position;
		this.selfEsteem = selfEsteem;
		cards = new Vector<Card>();
	}
	
	// Player constructor for loading player into the game
	public Player(String id, String name, String role, int position, int selfEsteem, Vector<Card> cards){
		this.number = id;
		this.name = name;
		this.role = role;
		this.position = position;
		this.selfEsteem = selfEsteem;
		this.cards = cards;
	}
	
	public String getID(){
		return number;
	}
	
	public String getName(){
		return name;
	}
	
	// Get the player location
	public int getPosition(){
		return position;
	}

	
	// Store the location of player
	public void move(int step){
		int totalNumberOfGrid = 28;
		position = position + step;
		if(position > totalNumberOfGrid){
			position = position % totalNumberOfGrid;
		}
	}
	
	// Add a card to a player
	public void addCard(Card card){
		cards.add(card);
	}
	
	// Get the card information
//	public Card getMagicTool(){
//		return cards.get(cards.size()-1);
//	}
	public Vector<Card> getMagicTool(){
		return cards;
	}
	// 
	public String getRole(){
		return role;
	}
	
	// 
	public int getSelfEsteem(){
		return selfEsteem;
	}
	
	public void addSelfEsteem(int value){
		selfEsteem += value;
	}
	
	// Check the availability of tool card (Magic Glove)
	public boolean hasMagicTools(){
		if(cards.size()> 0){			
			return true;			
		}		
		
		return false;
	}
	
	public void deleteCard(int cardID){
		for(int i=0; i<cards.size(); i++){
			if(cards.get(i).getCardID()==cardID){
				cards.remove(i);
				break;
			}
		}
	}
	
	public boolean hasMagicCrown(){
		if(cards.size()> 0){			
			for(int i=0; i<cards.size(); i++){
				if(cards.get(i).getCardName().equals("MagicCrown")){
					return true;
				}
			}
		}		
		return false;
	}
	
	public boolean hasMagicShield(){
		if(cards.size()> 0){			
			for(int i=0; i<cards.size(); i++){
				if(cards.get(i).getCardName().equals("MagicShield")){
					return true;
				}
			}
		}		
		return false;
	}
	
	public boolean hasMagicRod(){
		if(cards.size()> 0){			
			for(int i=0; i<cards.size(); i++){
				if(cards.get(i).getCardName().equals("MagicRod")){
					return true;
				}
			}
		}		
		return false;
	}
	
	public boolean hasMagicKey(){
		if(cards.size()> 0){			
			for(int i=0; i<cards.size(); i++){
				if(cards.get(i).getCardName().equals("MagicKey")){
					return true;
				}
			}
		}		
		return false;
	}
	
	public boolean hasMagicMirror(){
		if(cards.size()> 0){			
			for(int i=0; i<cards.size(); i++){
				if(cards.get(i).getCardName().equals("MagicMirror")){
					return true;
				}
			}
		}		
		return false;
	}
	
	public boolean hasMagicGlove(){
		if(cards.size()> 0){			
			for(int i=0; i<cards.size(); i++){
				if(cards.get(i).getCardName().equals("MagicGlove")){
					return true;
				}
			}
		}		
		return false;
	}

}
